package com.zhangbo.study.designpatternlearning.combination;

import java.util.Iterator;

public class Waitress {

    private PanckeHouseMenu panckeHouseMenu;

    private DinerMenu dinerMenu;

    public Waitress(PanckeHouseMenu panckeHouseMenu, DinerMenu dinerMenu) {
        this.panckeHouseMenu = panckeHouseMenu;
        this.dinerMenu = dinerMenu;
    }


    public void printMenu() {
        Iterator<MenuItem> panckeIterator = panckeHouseMenu.createIterator();
        Iterator<MenuItem> dinerIterator = dinerMenu.createIterator();
        System.out.println("MENU\n---\nBREAKFAST");
        printMenu(panckeIterator);
        System.out.println("\nLUNCH");
        printMenu(dinerIterator);
    }

    private void printMenu(Iterator<MenuItem> iterator) {
        while (iterator.hasNext()) {
            MenuItem next = iterator.next();
            System.out.println(next.getName() + ",  " + next.getPrice() + ",  " + next.getDescription());
        }
    }

}
